/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commons;

import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;

import java.util.Properties;

/**
 *
 * @author Adrian
 */
public class mail {

    private String name,topic,tresc,mail;

    public String send(){
      /*  String host = "ssl0.ovh.net";
	String port = "465";
        Properties props = new Properties();
		props.put("mail.smtp.user","els24@gruszowski.pl");
		props.put("mail.smtp.host", host);
		props.put("mail.smtp.port", port);
		props.put("mail.smtp.starttls.enable", "true");
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.socketFactory.port", port);
		props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.socketFactory.fallback", "false");
	System.getSecurityManager();
        Authenticator auth = new SMTPAuthenticator();
	Session session = Session.getInstance(props, auth);
        MimeMessage msg = new MimeMessage(session);
        try {
            msg.setSubject(topic);
            msg.setText(tresc);
            msg.setFrom(new InternetAddress(mail,name));
            msg.addRecipient(Message.RecipientType.TO,
            new InternetAddress("agruszowski@yahoo.com"));
            Transport.send(msg);
            return "ok";
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(mail.class.getName()).log(Level.SEVERE, null, ex);   
            return "fail";
        } catch (MessagingException ex) {
            Logger.getLogger(mail.class.getName()).log(Level.SEVERE, null, ex);
            return "fail";
        } */
        return null;
    }
    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getTresc() {
        return tresc;
    }

    public void setTresc(String tresc) {
        this.tresc = tresc;
    }
  
}
